<template>
	<view class="forum-card">
		<view class="container" v-for="(item, index) in forumData" :key="item.forumId">
			<uni-card @click="onClick(item.forumId)">
				<text class="title">
					{{ item.forumTitle }}
				</text>
				<text class="txt">
					{{ item.forumMessage }}
				</text>
				<view class="card-actions">
					<view class="right">
						<view class="card-actions-item" @click="actionsClick('评论')">
							<uni-icons type="chatbubble" size="20" color="#999"></uni-icons>
							<text class="card-actions-item-text">评论</text>
						</view>
					</view>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import store from '@/store/index.js'
	import {
		mapState,
		mapMutations,
		mapActions,
		mapGetters
	} from 'vuex'
	export default {
		components: {},
		data() {
			return {
				data: []
			};
		},
		methods: {
			...mapMutations('course', ['getForumData']),
			onClick(id) {
				uni.navigateTo({
					url: `/pages/forum/forum-detail/forum-detail?id=${id}`
				})
			},
			actionsClick(text) {
				uni.showToast({
					title: text,
					icon: "none",
				});
			},

		},
		computed: {
			...mapState('course', ['forumData']),
		},
		created() {
			this.getForumData()
		}

	};
</script>

<style scoped lang="scss">
	.title {
		color: #282c35;
		font-size: 40rpx;
		font-weight: 700;
		overflow: hidden;
		//自动换行，
		text-overflow: ellipsis;
		display: -webkit-box;
		//超出几行省略
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		word-break: break-all;
		letter-spacing: 2px;
	}

	.txt {
		margin-top: 30rpx;
		color: #282c35;
		font-size: 34rpx;
		overflow: hidden;
		//自动换行，
		text-overflow: ellipsis;
		display: -webkit-box;
		//超出几行省略
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		word-break: break-all;
	}

	.container {
		overflow: hidden;
	}

	.card-actions {
		// background-color: #666;

		display: flex;
		flex-direction: c;
		justify-content: center;
		align-items: center;
		height: 45px;
		border-top: 1px #eee solid;

		.left {
			// background-color: #666;
			width: 100%;
			height: 100%;
			line-height: 100rpx;
		}

		.left :active {
			color: #660d0d;
		}

		.right {
			// background-color: #666;
			width: 100%;
			height: 100%;
			line-height: 100rpx;
		}
	}

	.card-actions-item {
		// background-color: #666;
		margin-top: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		align-items: center;
	}

	.card-actions-item-text {
		font-size: 36rpx;
		color: #666;
		margin-left: 5px;
	}

	.no-border {
		border-width: 0;
	}
</style>